package org.jground.zk.zulX;

import org.jground.util.ArrayUtils;
import org.jground.zk.util.ZKUtils;
import org.zkoss.zk.ui.Component;
import org.zkoss.zul.Div;
import org.zkoss.zul.Label;

public class DivX extends Div {

    public DivX(Component... components) {
        for (Component component : components) {
            component.setParent(this);
        }
    }

    public DivX(String label) {
        new Label(label).setParent(this);
    }

    public void add(Component... components) {
        if (ArrayUtils.isNotEmpty(components)) {
            for (Component component : components) {
                if (component != null) {
                    component.setParent(this);
                }
            }
        }
    }

    public void set(Component... components) {
        removeAll();
        add(components);
    }

    public void removeAll() {
        ZKUtils.removeAllChildren(this);
    }

}
